#include <iostream>
using namespace std;
#include <stdio.h>
#include <cstring>


int g_array[10];
void writeFile()
{
    /* 打开文件 */
    FILE * fp = fopen("./record.txt","w");

    /* 写文件 */
    char buffer[128] = "hello world";
    fwrite(buffer, strlen(buffer), 1, fp);

    /* 关闭文件 */
    fclose(fp);
}

/* 读文件 */
void readFile()
{
    /* 打开文件 */
    FILE * fp = fopen("./record.txt","r");

    char buffer[128] = {0};
    fread(buffer,sizeof(buffer), 1, fp);

    cout<<"buffer:"<<buffer<<endl;

    /* 关闭文件 */
    fclose(fp);
}

/* 文件类 */
class myFile
{
public:
    myFile()
    {

    }
    myFile(const char * file, const char * openmode)
    {
        m_fp = fopen(file,openmode);
        if(m_fp == NULL)
        {
            printf("文件打开失败\n")；
        }
    }

    ~myFile()
    {
        if(m_fp != NULL)
        {
            fclose(m_fp);
            m_fp = NULL;
        }
    }
public:
    void open(const char * file,const char * openmode)
    {
        m_fp = fopen(file,openmode);
        if(m_fp == NUll)
        {
            printf("")
        }
    }

    bool

    /* 内容写入文件 */
    void write(const void * buf,size_t size)
    {
        fwrite(buf,size,1,m_fp);
    }

    /* 关闭文件 */
    void close()
    {
        fclose(m_fp);
    }



private:
    FILE * m_fp;
};

int main()
{
    myFile file("./record.txt","w+");

    if(file.is_opened())
    {
        const char * str = "262class cheer!"
    }

    const char * str = "Friday!";
    file.write(str,strlen(str));
    
    cout<<"hello world"<<endl;
    return 0;
}